//
//  Canvas.h
//  Shake and Bake
//
//  Created by Antoine Quint on 26/06/07.
//  Copyright 2007 Fuchsia Design. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <JavaScriptCore/JavaScriptCore.h>

#define NS_URI_SVG @"http://www.w3.org/2000/svg"
#define NS_URI_XLINK @"http://www.w3.org/1999/xlink"

#define ELEMENT_NAME_G @"g"
#define ELEMENT_NAME_SVG @"svg"
#define ELEMENT_NAME_RECT @"rect"
#define ELEMENT_NAME_CIRCLE @"circle"
#define ELEMENT_NAME_ELLIPSE @"ellipse"
#define ELEMENT_NAME_PATH @"path"
#define ELEMENT_NAME_TEXT @"text"
#define ELEMENT_NAME_ANIMATE @"animate"
#define ELEMENT_NAME_ANIMATE_TRANSFORM @"animateTransform"
#define ELEMENT_NAME_IMAGE @"image"
#define ELEMENT_NAME_VIDEO @"video"

#define ATTRIBUTE_NAME_ID @"id"
#define ATTRIBUTE_NAME_HREF @"href"
#define ATTRIBUTE_NAME_FILL @"fill"
#define ATTRIBUTE_NAME_STROKE @"stroke"
#define ATTRIBUTE_NAME_STROKE_WIDTH @"stroke-width"
#define ATTRIBUTE_NAME_OPACITY @"opacity"
#define ATTRIBUTE_NAME_FILL_OPACITY @"fill-opacity"
#define ATTRIBUTE_NAME_STROKE_OPACITY @"stroke-opacity"
#define ATTRIBUTE_NAME_TRANSFORM @"transform"
#define ATTRIBUTE_NAME_X @"x"
#define ATTRIBUTE_NAME_Y @"y"
#define ATTRIBUTE_NAME_WIDTH @"width"
#define ATTRIBUTE_NAME_HEIGHT @"height"

@class SVGElement;

@interface Canvas : NSView
{
	NSXMLParser *parser;
	CALayer *rootLayer;
  JSContextRef jsContext;
  JSObjectRef jsGlobal;
	NSMutableArray *elementsStack;
  NSMutableDictionary *namespaces;
  NSMutableDictionary *ids;
}

- (NSMutableDictionary *)ids;
- (void)loadFile:(NSString *)pathToFile;
- (SVGElement *)currentElement;
- (NSString *)getQNameForAttribute:(NSString *)localName inNamespace:(NSString *)namespaceURI;

@end